package deng.jpwh.hello;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;

import deng.jpwh.HibernateUtil;

public class HelloWorld {

	public static void main(String[] args) {
		
		Session session = HibernateUtil.getSessionFactory().openSession();
		
		Transaction tx = session.beginTransaction();
		
		Message m = new Message();
		m.setText("Hello_" + System.currentTimeMillis());
		session.persist(m);
		
		List<?> ls = session.createQuery("from Message").list();
		System.out.println(ls);
		
		tx.commit();
		session.close();
		HibernateUtil.shutdown();

	}

}
